#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> people(n);
    for (int i = 0; i < n; ++i) {
        people[i] = i + 1;
    }

    int out_count = 0;
    int index = 0;
    while (out_count < n) {
        int count = 0;
        while (count < m) {
            if (people[index]!= 0) {
                count++;
                if (count == m) {
                    cout << people[index] << " ";
                    people[index] = 0;
                    out_count++;
                }
            }
            index = (index + 1) % n;
        }
    }

    return 0;
}
